import {createRouter,createWebHashHistory,createWebHistory,createMemoryHistory} from "vue-router"
//1.声明routers配置，一个routes是一个数组，routers对象里面的基本属性由path和component组成
let routes =[
    {
        path:"/",
        component:()=>import("../pages/home/index.vue"),
        // 具名路由
        name:"/",
        // 路由元信息，每个路由都有一个meta属性，可以给路由配置添加一些额外的标识和属性
        meta:{
            // meta中的属性可以随便添
            name:"导航首页",
        },
        children:[
            {
                path:"discover",
                component: () => import("../pages/discover/index.vue"),
                name:"discover",
                meta:{
                    name:"发现首页"
                },
                // 重定向
                redirect:"/discover/playlist",
                // 嵌套路由,path不加/
                children:[
                    {
                        path:'playlist',
                        component:()=>import("../pages/discover/playlist/index.vue"),
                        name:"playlist",
                        meta:{
                            name:"歌单"
                        }
                    }
                ]
            },
            {
                path:"mine",
                component:()=>import("../pages/mine/index.vue"),
                name:"mine",
                meta:{
                    name:"个人中心"
                }
            },
            {
                //路由解耦合
                props:true,
                // 动态路由
                path:"friend/:id",
                component:()=>import("../pages/friend/index.vue"),
                name:"friend",
                meta:{
                    name:"朋友"
                }
            },
        ]
    },
    {
        path:"/login",
        component:()=>import("../pages/login/index.vue"),
        name:"login",
        meta:{
            name:"登录页"
        }
    },
]
// 2.创建路由
const router = createRouter({
    history:createWebHashHistory("/base"),
    routes
})
// 导出路由
export default router
